export default {
  data() {
    return {
      tableData: [],
      page: {
        currentPage: 1,
        pageSize: 20,
        recordsTotal: 0
      },
      tableMaxHeight: 500,
      formatChannelIdObj:{}
    };
  },
  methods: {
    pageChange(val) {
      this.getTableData({
        currentPage: val[0]
      });
    },
    setPage(page, target) {
      const sourcePage = target || this.page;
      sourcePage.currentPage = page.page || page.pageNo;
      // sourcePage.pageSize = page.pageSize;
      if (typeof page.totalRecord !== 'undefined') {
        sourcePage.recordsTotal = page.totalRecord;
      } else if (typeof page.totalCount !== 'undefined') {
        sourcePage.recordsTotal = page.totalCount || 0;
      } else if (typeof page.total !== 'undefined') {
        sourcePage.recordsTotal = page.total || 0;
      }
    },
    formatChannelId(productVal){
      if(!Object.keys(this.formatChannelIdObj).length){
        let productSource = this.$storage.get('Product');
        productSource && productSource.map((item)=>{
            item.value!=""&&(this.$set(this.formatChannelIdObj,item.value,item.label));
        });
      }
      return this.formatChannelIdObj[productVal]?this.formatChannelIdObj[productVal]:productVal;
    }
  }
};
